package com.zzpct.wh.work.shucheng.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.zzpct.wh.work.shucheng.Bean.Book;
import com.zzpct.wh.work.shucheng.R;

import java.util.List;
import java.util.ListIterator;

public class BookAdapter extends ArrayAdapter<Book> {
    int resourceid;

    public BookAdapter(@NonNull Context context, int resource, @NonNull List<Book> objects) {
        super(context, resource, objects);
        this.resourceid=resource;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        View view=convertView;
        if (view==null) {
            view = LayoutInflater.from(getContext()).inflate(resourceid, null);
        }
            ImageView bookimg = view.findViewById(R.id.bookimg);
            TextView bookname = view.findViewById(R.id.bookname);
            TextView authorname = view.findViewById(R.id.authorname);

            Book b=getItem(position);
            bookimg.setImageResource(b.getBookimg());
            bookname.setText(b.getBookname());
            authorname.setText("作者："+b.getAuthorname());
            return view;
        }
    }

